import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:junyeyishu/ui/home/widgets/QGLimitWidget.dart';

import 'package:junyeyishu/utils/utils.dart';
import 'package:junyeyishu/widgets/QGWidget.dart';

class QGSaleCell extends StatefulWidget {
  dynamic data;
  bool showLike;
  QGSaleCell({super.key, this.data, this.showLike = false});

  @override
  State<QGSaleCell> createState() => _QGSaleCellState();
}

class _QGSaleCellState extends State<QGSaleCell> {
  bool islike = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          color:Color(0XFF232A32), borderRadius: BorderRadius.circular(10.rpx)),
      child: Stack(
        children: [
          

          Column(
            children: [
              ClipRRect(
                borderRadius: BorderRadius.circular(10.rpx),
                child: AspectRatio(
                  aspectRatio: 1,
                  child: QGImage(url: widget.data?["thumb_img"]),
                ),
              ),
              buildBottom(),
            ],
          ),
          widget.data["onshelf_num"] == 0
              ? Positioned(
                  left: 36.rpx,
                  top: 48.rpx,
                  child: QGImage(asset: "delisted", width: 100.rpx),
                )
              : Container(),
          // Positioned(
          //     left: 5.rpx,
          //     top: 5.rpx,
          //     child:
          //         QGImage(url: widget.data?["goods_level_img"], width: 30.rpx)),
                  
          // Positioned(left: 0, bottom: 89.rpx, right: 0, child: buildLimit())
        ],
      ),
    );
  }

  buildLimit() {
    var circulationAmount = widget.data["circulation_amount"];
    var lotteriedNum = widget.data["lotteriedNum"];

    return SizedBox(
      width: 165.rpx,
      child: ClipRect(
        child: ClipRRect(
          borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10.rpx),
              bottomRight: Radius.circular(10.rpx)),
          child: Padding(
            padding: EdgeInsets.symmetric(horizontal: 10.rpx, vertical: 5.rpx),
            child: BackdropFilter(
              filter: ImageFilter.blur(
                  sigmaX: 3.0, sigmaY: 10.0, tileMode: TileMode.mirror),
              child: Container(
                alignment: Alignment.center,
                child: Text(
                  "流通量 ${lotteriedNum ?? circulationAmount}份",
                  style: TextStyle(fontSize: 11.rpx, color: Colors.white),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }

  buildBottom() {
    var circulationAmount = widget.data["circulation_amount"];
    var lotteriedNum = widget.data["lotteriedNum"];
    return Expanded(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 10.rpx),
            child: Text(
              widget.data?["name"] ?? "",
              style: TextStyle(
                  color: const Color(0xFFFFFFFF),
                  fontSize: 13.rpx,
                  fontWeight: FontWeight.bold),
            ),
          ),
          FittedBox(
            fit: BoxFit.contain,
            child: Row(
              children: [
                SizedBox(width: 10.rpx),
                QGLimitWidget(num: "${widget.data?["total"]}",dnum:"${lotteriedNum ?? circulationAmount}份"),
                SizedBox(width: 10.rpx),
              ],
            ),
          ),
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 10.rpx),
            child: Row(
              // mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text(
                      '￥${widget.data?["nft_price"]}',
                      style: TextStyle(
                          color: Color(0xFFFFFFFF),
                          fontSize: 16.rpx,
                          fontWeight: FontWeight.bold),
                    ),
                    SizedBox(width: 2.rpx),
                    Text(
                      '起',
                      style: TextStyle(
                          color: Color(0xFFFFFFFF),
                          fontSize: 11.rpx,
                          fontWeight: FontWeight.normal),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
